package com.qianbei.view.errotip;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;

import com.qianbei.R;
import com.qianbei.bean.GetCarbean2;
import com.qianbei.bean.GetErroBean;
import com.qianbei.common.base.BaseActivity;
import com.qianbei.common.init.SetData;
import com.qianbei.common.net.control.ServerControl;
import com.qianbei.common.net.control.ServerResult;
import com.qianbei.common.net.okhttp.RequeastBean;
import com.qianbei.common.net.view.MsgAlert;
import com.qianbei.common.net.view.ProgressDialog;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ErroTipActivity extends BaseActivity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gufei_erro_acitivty);
        ButterKnife.bind(this);
        setTitle("异常报警");
    }



    @OnClick({R.id.tip_1, R.id.tip_2, R.id.tip_3, R.id.tip_4, R.id.tip_5})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tip_1:
                show();
                break;
            case R.id.tip_2:
                startActivity(TactionActivity.class);
                break;
            case R.id.tip_3:
                startActivity(AccidentActivity.class);
                break;
            case R.id.tip_4:
                startActivity(OtherReasonActivity.class);
                break;
            case R.id.tip_5:
                startActivity(CustomerReasonActivity.class);
                break;
        }
    }

    public  void show(){
        AlertDialog dialog = new AlertDialog.Builder(this)
//                .setTitle("是否绑定此车")//设置对话框的标题
                .setMessage("是否确定车辆满载（未完成路线）")//设置对话框的内容
                //设置对话框的按钮
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        interrupt();
                        dialog.dismiss();
                    }
                }).create();
        dialog.show();
    }

    /**
     * 上报 异常报警 - 车辆满载
     *
     */
    private void interrupt() {

        ServerControl sc = new ServerControl(
                new RequeastBean("interrupt","com.cygps.dubbo.WasteTransport.IRouteInfo",
                        new GetErroBean("1")));
        sc.serverListener = new ServerControl.ServerListener() {

            @Override
            public void serverFinish(ServerResult sr) {
                if (sr.isContinue) {
                    new MsgAlert().show("上报成功");
                }

            }
        };
        new ProgressDialog(mContext).OKpost(sc);
    }
}
